<?php

namespace App\Common\Traits;

use App\Models\System\SystemLog;
use App\Models\System\SystemOperationLog;

trait LogTrait
{
    //
    public function saveSystemLog($type,$info,$param='',$extra=''):void
    {
        // SystemLog::create([
        //     'type' => $type,
        //     'info' => is_string($info) ? $info : json_encode($info),
        //     'param' => is_string($param) ? $param : json_encode($param),
        //     'extra' => is_string($extra) ? $extra : json_encode($extra),
        // ]);
    }
    //
    public function saveExceptionLog($type,$exception,$param='',$extra=''):void
    {
        // SystemLog::create([
        //     'type' => $type,
        //     'info' => 'file:'.$exception->getFile().'; line:'.$exception->getLine().'; msg:'.$exception->getMessage(),
        //     'param' => is_string($param) ? $param : json_encode($param),
        //     'extra' => is_string($extra) ? $extra : json_encode($extra),
        // ]);
    }

    //
    public function saveOperationLog($operation_type='',$data='',$extra=''):void
    {
        // SystemOperationLog::create([
        //     'strator_id' => request()->user()?->id??0,
        //     'operation_type' => $operation_type,
        //     'original_data' => is_string($data) ? $data : json_encode($data),
        //     'param' => json_encode(request()->all())??'',
        //     'extra' => is_string($extra) ? $extra : json_encode($extra),
        // ]);
    }

}
